// 树状菜单

//       1. 每一个 ul 下的 li 点击的时候
//         => 自己的 ol 切换显示和隐藏
//         => 所有兄弟元素的 ol 隐藏
//         => 自己的 active 类名切换
//         => 所有兄弟元素的 active 类名消失
    

$('ul > li').click(function () {
  // 切换自己的内容
  $(this).toggleClass('active').find('ol').slideToggle(300)

  // 切换兄弟元素的内容
  $(this).siblings().removeClass('active').find('ol').slideUp(400)
})
// 获取元素
const pie = document.querySelector('.pie')
const pi = document.querySelector('.pi')
console.log(pie)
console.log(pi)
const ulBox = document.querySelector('.page')
// 请求数据时用的参数
const inf = {
    data: 0,  
    status: 2,
    user: "",
    id_goods:'104265,103262,104101,103643,103594,104083,104084,104086,104087,103642,103632,103641,103497,102476,103634,103633,103508,103406,103516,103627,103500,103501,103602,103626,103628,103636,103637,103638,102269,102270,102271,102291,102277,102280,102281,102282,102284,102289,102251,102252,102262,81683,80425,88643,84038,82296,81588,82166,80383,79381,79691,87464,88748,79798,88656,87393,88702,103828,103829,103830,103831,87448,87451,83947,82959,88597,88654,87409,87436,87438,87439,87444,87447,87449,83884,88749,88768,83921,82167,92920,83974,82953,87408,103813,103814,103815,103816,103817,103818,103819,103820,103825,103826,87443,103827,87453,83928,83967,88610,88619,103807,103808,103809,103810,103811,92870,92871,88847,88871,88622,88718,88720,88757,88604,87401,101756,88797,103758,103759,103760,103761,103762,103763,103764,103765,103766,103767,103768,103769,103770,103771,103772,103774,103775,103776,103777,103778,103779,103780,103781'
}
// 渲染商品
shopList()
async function shopList(){

  const res = await pAjax({
    url:'/index',
    dataType:'json',
    data:inf,
    menthod:'POST'
  })
  console.log(res)
  let i = 0
  res.data.forEach(item => {
    i++
  const str = `
    <li>
      <img src="${item.info.image}">
      <p>${item.info.pro_name}</p>
      <p>￥ ${item.info.price}</p>
    </li>
    `
    ulBox.innerHTML += str
    pi.innerHTML = `(${i})`
    pie.innerHTML = `(${i})`

  })
}


